package com.vtuzx.kingdee.xqc_core.dao;

import com.vtuzx.core.bean.dto.VtuzxMap;
import com.vtuzx.core.constant.IVtuzxConst;
import com.vtuzx.core.db.mongo.impl.VtuzxDaoImpl;
import org.bson.Document;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * 对接系统接口履历Dao
 */
@Component
public class TrayDao extends VtuzxDaoImpl {
    /** 集合名称 */
    public static final String NAME = "t_tray";

    public TrayDao() {
        super(NAME);
    }

    public Iterator<Document> trayGroup(Criteria cond) {
        Document groupId = new Document("ip", "$ip");
        List<Document> pipes = new ArrayList<>();
        pipes.add(new Document("$match", cond.getCriteriaObject()));
        pipes.add(new Document("$group", new Document(IVtuzxConst.Key__id, groupId).append("maxDate", new Document("$max", "$lastInventoryTime"))));
        return aggregate(pipes);
    }

}